package spring.cloud.tasks.client.item_task_processor;

import lombok.Getter;
import lombok.Setter;

import java.util.List;


public class Task {

    public static String status_run = "resume";
    public static String status_pause = "pause";
    @Setter
    @Getter
    private String taskId;
    @Setter
    @Getter
    private String taskName;
    @Setter
    @Getter
    private String runCronExpressionString;
    @Setter
    @Getter
    private String pauseCronExpressionString;
    @Setter
    @Getter
    private String[] taskItems;
    @Setter
    @Getter
    private String taskParameter;
    //******************************我是优雅的分割线******************************
    @Setter
    @Getter
    private List<String> ipList;
    //******************************我是优雅的分割线******************************
    //调度器信息
    @Setter
    @Getter
    private int totalProcessorCount;
    @Setter
    @Getter
    private int threadCountPerTaskProcessor = 5;
    //如果有该标记 代表现在只是单机处理,那么调度器在真正创建处理的时候最多不能超过5个。
    @Setter
    @Getter
    private boolean onlyOneWorkerDealWithTask = false;
    //******************************我是优雅的分割线******************************
    @Setter
    @Getter
    private int threadCountPerProcessorWhenOnlyOneWorkerDealWithTask = 2;//避免CPU处理过快
    /**
     * resume,pause
     */
    @Setter
    @Getter
    private String status = status_run;
    @Setter
    @Getter
    private int fetchSize = 100;//10000时间太长 1000都比较久了 同时在taskItem进行重新分配造成数据重复处理可能性大
    @Setter
    @Getter
    private int maxExecuteSize = 1;
    //******************************我是优雅的分割线******************************
    //@Setter
    @Getter
    private long heartBeatRate = 1000 * 5;
    //@Setter
    @Getter
    private long judgeDeadInterval = heartBeatRate * 12;
    //******************************我是优雅的分割线******************************
    @Setter
    @Getter
    private int waitPublishedTaskItemsVersion = 0;//待公布的版本
    @Setter
    @Getter
    private int taskItemsVersion = 0;//最新有效版本

    public int getMinThreadCountPerProcessor() {
        return onlyOneWorkerDealWithTask ? threadCountPerProcessorWhenOnlyOneWorkerDealWithTask : threadCountPerTaskProcessor;
    }

}
